{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 151,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "from scipy.stats import dirichlet\n",
    "import matplotlib.pyplot as plt\n",
    "import matplotlib.tri as mtri\n",
    "plt.rcParams['figure.figsize']=(8,8)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 152,
   "metadata": {},
   "outputs": [],
   "source": [
    "x=np.linspace(0,1,100)\n",
    "y=np.linspace(0,1,100)\n",
    "xx,yy=np.meshgrid(x,y)\n",
    "zz=1-xx-yy\n",
    "zz\n",
    "temp_loc=np.dstack((xx,yy,zz))\n",
    "loc=temp_loc[(zz>0)&(xx>0)&(yy>0)]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 167,
   "metadata": {},
   "outputs": [],
   "source": [
    "alpha =np.array([0.1,0.1,0.1])\n",
    "new_pos = loc[0,:]\n",
    "new_pos\n",
    "density = [dirichlet.pdf(single_loc,alpha) for single_loc in loc]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 163,
   "metadata": {},
   "outputs": [],
   "source": [
    "triang = mtri.Triangulation(loc[:,0],loc[:,1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 168,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.tri.tricontour.TriContourSet at 0x14062b38>"
      ]
     },
     "execution_count": 168,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAecAAAHVCAYAAADLvzPyAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvIxREBQAAFxRJREFUeJzt3W+IrvV95/HPV93TCLGuXatLHZPYYEKtGAIH6boP1my7xRNYfVKqQhYCIYEFe7o0FFy6hGKfbJOGgOAulX1QCKTW7oPW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ydJVf1Czsf5271OuSDiPFGttTeS3JfkiSTPJ3m0tfZsVT1QVXduLvtMkncm+dOq+ruq2v4vGx11PN+sSMfz/USSV6vquSRPJvnt1tqrw0w8bR3P9yeTfLyqvpbkj5N8tPlxn7Xxo1QAMDJ2zgAwMuIMACMjzgAwMuIMACMjzgAwMuIMACMjzgAwMv8fbVSEHAiCWbUAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 576x576 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.tricontourf(triang,density)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
